#include "plane.h"

plane::plane()
{
    plane_pixmap.load(PLANE_PATH);

    plane_x=(GAME_WIDTH-PLANE_WIDTH)*0.5;
    plane_y=GAME_HEIGHT-PLANE_HEIGHT;

    plane_rect.setWidth(PLANE_WIDTH);
    plane_rect.setHeight(PLANE_HEIGHT);

    plane_rect.moveTo(plane_x,plane_y);

    bullet_recorder=0;
}

void plane::shoot()
{
    bullet_recorder++;

    if(bullet_recorder<BULLET_INTERVAL){
        return;
    }

    bullet_recorder=0;

    for(int i=0;i<BULLET_NUM;i++){
        if(Bullet[i].bullet_free){
            Bullet[i].bullet_free=false;
            Bullet[i].bullet_x=plane_x+13;
            Bullet[i].bullet_y=plane_y-25;
            break;
        }
    }
}

void plane::setplanePosition(int x,int y)
{
    plane_x=x;
    plane_y=y;
    plane_rect.moveTo(plane_x,plane_y);
}
